package com.kkb.dao.impl;

import com.kkb.dao.TeamDao;
import com.kkb.pojo.Team;
import com.kkb.utils.MybatisUtil;
import org.apache.ibatis.session.SqlSession;

import java.util.List;

public class TeamDaoImpl implements TeamDao {

    SqlSession sqlSession = MybatisUtil.getSqlSession();

    @Override
    public List<Team> findAll() {
        List<Team> teamList = sqlSession.selectList("com.kkb.pojo.Team.findAll");
        return teamList;
    }

    @Override
    public Team findById(Integer teamId) {
        Team team = sqlSession.selectOne("com.kkb.pojo.Team.findById",teamId);
        return team;
    }

    @Override
    public int add(Team team) {
        int num = sqlSession.insert("com.kkb.pojo.Team.add",team);
        sqlSession.commit();
        return num;
    }

    @Override
    public int update(Team team) {
        int num = sqlSession.update("com.kkb.pojo.Team.update",team);
        sqlSession.commit();
        return num;
    }

    @Override
    public int delete(Integer teamId) {
        int num = sqlSession.update("com.kkb.pojo.Team.delete",teamId);
        sqlSession.commit();
        return num;
    }
}
